package com.gsit.job.services;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import org.springframework.stereotype.Component;

import com.gsit.job.config.Config;
import com.gsit.job.domain.Person;

@Component
public class PersonFileWriter {

	
	
	public void write(Person person,String fileText){
		try {
			String fileName = "resid_"+person.getResid()+"_uid_"+person.getResid()+".html";
			File file = new File(Config.FOLDER_PATH+fileName);
 
			if (!file.exists()) {
				file.createNewFile();
			}
 
			FileWriter fw = new FileWriter(file.getAbsoluteFile());
			BufferedWriter bw = new BufferedWriter(fw);
			bw.write(fileText);
			bw.close();
 
 
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	

}
